package top.songxs.gmall.product.controller;

import org.checkerframework.checker.index.qual.GTENegativeOne;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.product.entity.SpuSaleAttr;
import top.songxs.gmall.product.service.SpuSaleAttrService;

import java.util.List;

@RestController
@RequestMapping("admin/product")
public class SpuSaleAttrController {

    @Autowired
    private SpuSaleAttrService spuSaleAttrService;

    //http://api.gmall.com/admin/product/spuSaleAttrList/{spuId}
    //spuId：spuId
    //Get
    //http://api.gmall.com/admin/product/spuSaleAttrList/4

    @GetMapping("spuSaleAttrList/{spuId}")
    public Result<List<SpuSaleAttr>> getSpuSaleAttrListBySpuId(@PathVariable("spuId") Long spuId){
        List<SpuSaleAttr> list = spuSaleAttrService.getSpuSaleAttrListBySpuId(spuId);
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
}
